
The {\it Post\underline{p}oned Conflict Resolution} is a strategy (PPCR strategy)
to apply whenever there is a shift-reduce or reduce-reduce conflict which is
unsolvable using static precedences. It delays the decision, whether to shift
or reduce and by which production to reduce, to parsing time.
Let us assume the \verb|yacc|/\verb|eyapp| \mbox{compiler \cite{Rodriguez:Leon}}
announces  the presence of
a reduce-reduce conflict.
The steps followed to solve a reduce-reduce conflict using the
PPCR strategy are:

\begin{enumerate}
\item
Identify and understand the conflict: What LR(0)-items/productions and tokens are involved?.

Tools must support that stage, as for example via  the \verb|.output| file generated by \verb|eyapp| 
using option \verb|-v| or the graphical description obtained using option \verb|-w| or 
with the help of expert systems \cite{passos,basten}.
Suppose  we identify that the participants are two LR(0)-items \mbox{$A \rightarrow \alpha_\uparrow$}
and
$B \rightarrow \beta_\uparrow$ when the lookahead token is \verb|@|.

\item The software must allow the use of symbolic labels to refer
by name to the productions involved in the conflict.
Let us assume that production $A \rightarrow \alpha$
has label \texttt{:rA} and production $B \rightarrow \beta$
has label \texttt{:rB}.
A difference with \verb|yacc| is that
in \verb|Parse::Eyapp| productions can have {\it names} and {\it labels}.
In \verb|Eyapp| names and labels can be
explicitly given using the directive \verb|%name|, using a syntax similar to this one:

\begin{eqnarray*}
\mbox{{\tt \%name :rA}}& A &\rightarrow \alpha\\
\mbox{{\tt \%name :rB}}& B &\rightarrow \beta 
\end{eqnarray*}


\item
Give a symbolic name to the conflict. In this case we choose \verb|isAorB|
as name of the conflict.

\item
\label{item:mark}
Inside the {\it body} section of the grammar, mark the points of conflict using the
new reserved word \verb|%PREC| followed by the conflict name:

\begin{eqnarray*}
\mbox{{\tt \%name :rA\ }}    A &\rightarrow \alpha &\mbox{\tt\ \%PREC IsAorB }\\
\mbox{{\tt \%name :rA\ }}    B &\rightarrow \beta  &\mbox{\tt\ \%PREC IsAorB }
\end{eqnarray*}
\item
\label{item:handler}
Introduce a \verb|%conflict| directive inside the {\it head} section of
the translation scheme to specify the way the conflict will be solved.
The directive is followed by some code - known as the {\it conflict handler} -
whose mission is to modify
the parsing tables. This code will be executed
each time the associated conflict state is reached.
This is the usual layout of the conflict handler:

\begin{center}
\begin{tabular}{p{8cm}}
\begin{verbatim}
%conflict  IsAorB {
  if ($is_A) { $self->YYSetReduce(':rA' ); } 
       else { $self->YYSetReduce(':rB' ); }
}
\end{verbatim}
\end{tabular}
\end{center}

Inside a conflict code handler the Perl default variable \verb|$_| refers to
the input and \verb|$self| refers to the parser object.

%\begin{quotation}
Variables in Perl - like \verb|$self| -
have prefixes like \verb|$| (scalars),
\verb|@| (lists), \verb|%| (hashes or dictionaries), \verb|&| (subroutines), etc.
specifying the type of the variable. These prefixes are called {\it sigils}.
The sigil \verb|$| indicates a {\it scalar} variable, i.e. a variable that stores a single value:
a number, a string or a reference. In this case \verb|$self| is a reference to the parser object.
The arrow syntax \verb|$object->method()| is used to call a method: it is the equivalent
of the dot operator \verb|object.method()| used in most
OOP languages. Thus the call

\begin{center}
\begin{tabular}{p{5cm}}
\begin{verbatim}
$self->YYSetReduce(':rA' ) 
\end{verbatim}
\end{tabular}
\end{center}

is a call to the
\verb|YYSetReduce| method of the object \verb|$self|.
%\end{quotation}

The method \verb|YYSetReduce| provided by \verb|Parse::Eyapp| receives a 
production label, like \verb|:rA|. The former call
sets the parsing action
for the state associated with the
conflict \verb|IsAorB| to
reduce by the production \verb|:rA| for the tokens involved in the conflict.

\item
The value \verb|$is_A|
represents the context-dependent
dynamic knowledge that allows us to take the right
decision.
It is usually the result of a call to a nested parser of a subgrammar component 
of the main grammar, but it can also be any other contextual information we have
to determine which one is the right production. 

The general procedure is 
to identify suitable {\it exploration points} in the right hand side of some productions.
They are  marked inside
the grammar body using the \verb|%conflictname?| syntax:
\begin{center}
\begin{tabular}{p{5cm}}
\begin{VERBATIM}[numbers=none,codes={\catcode`$=3\catcode`\_=8\catcode`^=7}] 
C: $\lambda_1$ \textbf{%AorB?} $\lambda_2$
\end{VERBATIM}
\end{tabular}
\end{center}
The set of exploration points must hold the following covering property:
any visit to the conflictive state must be preceded by a visit to 
an exploration state. The exploration states have associated {\it an exploration
code} which is given (explicitly or implicitly) through a \verb|%explorer| directive.
Its goal is to determine which production applies.
That directive is set inside the head section, and often follows this pattern (see section 
\ref{section:simpleexample}
for an example):
\begin{center}
\begin{tabular}{p{6.2cm}}
\begin{VERBATIM}[numbers=none, codes={\catcode`$=3\catcode`\_=8}]
\textbf{%explorer AorB D}
%% /* body section */
\ldots
\end{VERBATIM}
\end{tabular}
\end{center}
where \verb|D| is an auxilary syntactic variable.
The former directive is translated by the \verb|eyapp|
compiler into  the following exploration code:
\begin{center}
\begin{tabular}{p{5.8cm}}
\begin{VERBATIM}[numbers=none, codes={\catcode`$=3\catcode`\_=8}]
\Dr{}is\_A = \textbf{\Dr{}self->YYPreParse('D')}; 
\end{VERBATIM}
\end{tabular}
\end{center}
The call \verb|$self->YYPreParse(D)|
returns true if, and only if there is a prefix of the unexpended input
that belongs to the language defined by \verb|D|. 
The language defined by \verb|D|
must characterize the \verb|$is_A| condition: any incoming 
input belongs to the language if, and only if, 
$A \rightarrow \alpha_\uparrow$ is a suitable the handler
for the anti-derivation.


%but does not exist a derivation $\lambda_2 \derives \nu_1 B \nu_2$
\end{enumerate}


